/**
 * @description Description
 *
 * @author Candy <candy.yan@motionglobal.com>
 * @date  Creation Date 2018/7/24
 */
import ApiPath from "@/mock-data/ApiPath"
const Mock = require("mockjs")

var user = {
  username: 'admin',
  // password: 'motion888'
  password: 'acb169575b7735eef8f5f4caebaa5cb5'
}
let loginDate = new Date().toUTCString();
Mock.mock(ApiPath.user.login, "post", function (options) {
  var valid = Mock.valid(user, JSON.parse(options.body));
  if (valid.length > 0) {
    return {
      "status": 0,
      "error": valid[0].message,
      "msg": "Login Fail!"
    }
  } else {
    return {
      "status": 1,
      "data": {
        "user_id": 1,
        "username": "admin",
        "login_time": loginDate
      },
      "msg": "Login Successful!"
    }
  }
});
Mock.mock(ApiPath.user.passwordReset, "post", function (options) {
  var valid = Mock.valid(user, JSON.parse(options.body));
  if (valid.length > 0) {
    return {
      "status": 0,
      "error": valid[0].message,
      "msg": "Password Reset Fail!"
    }
  } else {
    return {
      "status": 1,
      "data": {
        "user_id": 1,
        "username": "admin",
      },
      "msg": "Password Reset Successful!"
    }
  }
});
Mock.mock(ApiPath.user.logout, "post", function (options) {
  return {
    status: 1,
    "msg": "Logout Successful!"
  }
});
Mock.mock(ApiPath.user.getUserInfo + "?user_id=1", "get", {
  "status": 1,
  "data": {
    "user_id": 1,
    "username": "admin",
    "login_time": loginDate
  }
});

